<!--这是确认发货组件-->
<template>
	<div v-loading="listLoading">
		<p class="filter"></p>
		<div class="addBox"  style="padding-bottom: 40px;">
			<h3 class="fixTitle">
				<span>确认发货</span>
				<p>
					<em style="cursor: pointer;" ><svg-icon icon-class="jian" class="font-size16"/></em><em style="cursor: pointer;"><svg-icon class="font-size16" icon-class="fullScreen" /></em><em style="cursor: pointer;" @click="close"><svg-icon icon-class="cha" class="font-size16" /></em>
				</p>
			</h3>
			<div style="margin: 20px;">
				<table>
					<tr>
						<td class="leftTd">承运商：</td>
						<td class="rightTd">
							<el-select clearable style="width: 250px;" v-model="shipId" placeholder="请选择类型">
							    <el-option
							      v-for="item in ships"
							      :key="item.shipId"
							      :label="item.name"
							      :value="item.shipId">
							    </el-option>
							</el-select>
						</td>
					</tr>
					<tr>
						<td class="leftTd">快递单号：</td>
						<td class="rightTd"><el-input v-model="shipNo" clearable placeholder="请输入快递单号" style="width: 250px;"></el-input></td>
					</tr>
				</table>
			</div>
			<p style="text-align: center;margin: 30px 0;">
				<el-button @click="save" type="primary" icon="el-icon-check">确认</el-button>
	  		<el-button type="info" @click="close">取消</el-button>
			</p>
		</div>
	</div>
</template>
<script>
import { sendGoods } from '@/api/goods'
export default {
  props: ['ships', 'orderId'],
  data() {
    return {
      shipNo: null, // 快递单号
      shipId: null, // 快递类型
      listLoading: false
    }
  },
  methods: {
    close() {
      this.$emit('hideSend', false)
    },
    save() {
      if (!this.shipId | !this.shipNo) {
        this.$message({
          type: 'error',
          message: '填写不完整!'
        })
        return
      }
      var data = { goId: this.orderId, shipId: this.shipId, shipNo: this.shipNo }
      this.listLoading = true
      sendGoods(data).then(res => {
      	this.listLoading = false
        this.$message({
          type: 'success',
          message: '发货成功!'
        })
        this.$emit('successSend', { expressId: this.shipId, shipNo: this.shipNo, deliverAt: res.data.data })
      }).catch(err => {
      	this.listLoading = false
        console.log(err)
      })
    }
  }
}
</script>
<style scoped>
	p,h3 {margin:0;padding:0}
	h3 em{
		padding: 0 5px;
		font-style: normal;
	}
	h3 em:hover{
		color: #0E90D2;
	}
	.font-size16{
		font-size: 16px;
	}
	.fixTitle{
		font-weight: 500;
		font-size: 14px;
		height: 36px;
		background: #eee;
		border-bottom: 1px solid #ddd;
		position: fixed;
		width: 400px;
		line-height: 36px;
		padding: 0 10px;
		z-index: 98;
	}
	.fixTitle p{
		position: absolute;
		right: 20px;
		top: 0px;
	}
	.filter {
		width: 100%;
		height: 100%;
		background: rgba(0,0,0,.3);
		position: fixed;
		left: 0;
		top: 0;
		z-index: 90;
	}
	.addBox {
		width: 400px;
		height: auto;
		background: #fff;
		position: fixed ;
		left: 35%;
		top: 30%;
		z-index: 101;
	}
	table{
		width: 100%;
		border: 1px solid #eee;
		border-spacing: 0;
		border-collapse: collapse;
		margin-top: 40px;
	}
	td{
		border: 1px solid #eee;
		line-height: 50px;
		padding-left: 10px;
	}
	.leftTd{
		width: 30%;
	}
	.rightTd{
		width: 70%;
	}
</style>
